package com.liujun.microserver.auth2.webjoin.server.security;

import java.util.Collection;
import java.util.HashSet;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import com.liujun.microserver.auth2.webjoin.server.bean.ClientUser;

/**
 * 1,用户身份信息
 * 
 * @author liujun
 * @date 2018/07/01
 */
public class ClientUserDetails implements UserDetails {

	/**
	 *
	 */
	private static final long serialVersionUID = 1L;

	private ClientUser clientUser;

	public ClientUserDetails(ClientUser clientUser) {
		this.clientUser = clientUser;
	}

	public ClientUser getClientUser() {
		return clientUser;
	}

	@Override
	public Collection<? extends GrantedAuthority> getAuthorities() {
		return new HashSet<>();
	}

	@Override
	public String getPassword() {
		return clientUser.getPassword();
	}

	@Override
	public String getUsername() {
		return clientUser.getUsername();
	}

	@Override
	public boolean isAccountNonExpired() {
		return true;
	}

	@Override
	public boolean isAccountNonLocked() {
		return true;
	}

	@Override
	public boolean isCredentialsNonExpired() {
		return true;
	}

	@Override
	public boolean isEnabled() {
		return true;
	}

}
